package com.osce.go_score.controller;

import com.csce.domain.entity.go_score.GoScoreExamStudent;
import com.osce.common.annotation.Log;
import com.osce.common.core.controller.BaseController;
import com.osce.common.core.entity.AjaxResult;
import com.osce.common.core.page.TableDataInfo;
import com.osce.common.enums.BusinessType;
import com.osce.common.utils.poi.ExcelUtil;
import com.osce.interfaces.go_score.IGoScoreExamStudentService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 妇产科考试考场-学生Controller
 *
 * @author ruoyi
 * @since 2024-05-17
 */
@RestController
@RequestMapping("/go_score/go_score_exam_student")
public class GoScoreExamStudentController extends BaseController {

    @Resource
    private IGoScoreExamStudentService goScoreExamStudentService;

    /**
     * 查询妇产科考试考场-学生列表
     */
    @PreAuthorize("@ss.hasPermi('go_score:go_score_exam_student:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoScoreExamStudent goScoreExamStudent) {
        startPage();
        List<GoScoreExamStudent> list = goScoreExamStudentService.selectGoScoreExamStudentList(goScoreExamStudent);
        return getDataTable(list);
    }

    /**
     * 导出妇产科考试考场-学生列表
     */
    @PreAuthorize("@ss.hasPermi('go_score:go_score_exam_student:export')")
    @Log(title = "妇产科考试考场-学生", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoScoreExamStudent goScoreExamStudent) {
        List<GoScoreExamStudent> list = goScoreExamStudentService.selectGoScoreExamStudentList(goScoreExamStudent);
        ExcelUtil<GoScoreExamStudent> util = new ExcelUtil<GoScoreExamStudent>(GoScoreExamStudent.class);
        util.exportExcel(response, list, "妇产科考试考场-学生数据");
    }

    /**
     * 获取妇产科考试考场-学生详细信息
     */
    @PreAuthorize("@ss.hasPermi('go_score:go_score_exam_student:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(goScoreExamStudentService.selectGoScoreExamStudentById(id));
    }

    /**
     * 新增妇产科考试考场-学生
     */
    @PreAuthorize("@ss.hasPermi('go_score:go_score_exam_student:add')")
    @Log(title = "妇产科考试考场-学生", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoScoreExamStudent goScoreExamStudent) {
        return toAjax(goScoreExamStudentService.insertGoScoreExamStudent(goScoreExamStudent));
    }

    /**
     * 修改妇产科考试考场-学生
     */
    @PreAuthorize("@ss.hasPermi('go_score:go_score_exam_student:edit')")
    @Log(title = "妇产科考试考场-学生", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoScoreExamStudent goScoreExamStudent) {
        return toAjax(goScoreExamStudentService.updateGoScoreExamStudent(goScoreExamStudent));
    }

    /**
     * 删除妇产科考试考场-学生
     */
    @PreAuthorize("@ss.hasPermi('go_score:go_score_exam_student:remove')")
    @Log(title = "妇产科考试考场-学生", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(goScoreExamStudentService.deleteGoScoreExamStudentByIds(ids));
    }
}
